/**
 * Flight Info Application
 */
package com.dlplay.flightinfo.server;

import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.routing.Router;

import com.dlplay.flightinfo.server.resource.AgencyResource;
import com.dlplay.flightinfo.server.resource.AirlineListResource;
import com.dlplay.flightinfo.server.resource.AirlineResource;
import com.dlplay.flightinfo.server.resource.AirportListResource;
import com.dlplay.flightinfo.server.resource.AirportResource;
import com.dlplay.flightinfo.server.resource.ClientResource;
import com.dlplay.flightinfo.server.resource.FlightResource;
import com.dlplay.flightinfo.server.resource.RegisterResource;
import com.dlplay.flightinfo.server.resource.SystemResource;
import com.dlplay.flightinfo.server.resource.TicketResource;
import com.dlplay.flightinfo.server.resource.UpdateFlightTask;


/**
 * @author zhao yu
 *
 */
public class FlightInfoApplication extends Application {
	/* (non-Javadoc)
	 * @see org.restlet.Application#createInboundRoot()
	 */
	@Override
	public Restlet createInboundRoot() {		
		getLogger().info("createInboundRoot");
		// Create a router Restlet that defines routes.
		Router router = new Router(getContext());
	
		// Defines a route for the resource "list of Flight"
//		router.attach("/Flights", FlightListResource.class);
		// Defines a route for the resource "item"
		router.attach("/Flight/{flightNum}", FlightResource.class);

		// Defines a route for the resource "item"
		router.attach("/Client/", ClientResource.class);

		// Defines a route for the resource "item"
		router.attach("/System/{status}", SystemResource.class);

		// Defines a route for the resource "item"
		router.attach("/Ticket/{query}", TicketResource.class);
		
		// Defines a route for the resource "list of Airport"
		router.attach("/Airports", AirportListResource.class);
		
		// Defines a route for the resource "item"
		router.attach("/Airport/{city}", AirportResource.class);
		
		// Defines a route for the resource "list of Airport"
		router.attach("/Airlines", AirlineListResource.class);
		
		// Defines a route for the resource "item"
		router.attach("/Airline/{airline}", AirlineResource.class);
		
		// Defines a route for the resource "item"
		router.attach("/Register/{flightNum}/{content}", RegisterResource.class);
		
		// Defines a route for the resource "item"
		router.attach("/Agency", AgencyResource.class);
		
		// Defines a route for the resource "item"
		router.attach("/cron/updateFlight", UpdateFlightTask.class);
		
		return router;
	}

}
